#pragma once
#include "../MemPtr.h"

struct CItemID
{
	CItemID(PCUIDLIST_RELATIVE ItemID)
		: _pidl(ItemID)
	{
	}

	bool IsEmpty() const
	{
		return ::ILIsEmpty(_pidl);
	}

	CItemID Next() const
	{
		return CItemID(::ILNext(_pidl));
	}

protected:

	PCUIDLIST_RELATIVE _pidl;
};

struct CItemIDList : CItemID
{
	explicit CItemIDList()
	{
	}

	explicit CItemIDList(ITEMIDLIST_RELATIVE ItemIDList)
		: CItemID(ItemIDList)
	{
	}

	~CItemIDList()
	{
		if (_pidl != NULL)
		{
			::CoTaskMemFree(_pidl);
			_pidl = NULL;
		}
	}

	void Append(CItemID & ItemID)
	{
		_pidl = ::ILAppendID(_pidl, ItemID._pidl, TRUE);
	}

	void Prepend(CItemID & ItemID)
	{
		_pidl = ::ILAppendID(_pidl, ItemID._pidl, FALSE);
	}
};